package job

import (
	"flag"
	"fmt"

	"code.bydev.io/cht/customer/kyc_admin_service/service/job/internal/config"
	"code.bydev.io/cht/customer/kyc_admin_service/service/job/internal/handler"
	"code.bydev.io/cht/customer/kyc_admin_service/service/job/internal/svc"
	"code.bydev.io/frameworks/byone/core/conf"
	"code.bydev.io/frameworks/byone/zcron"
)

var configFile = flag.String("job_config", "../conf/cron.toml", "the config file")

func JobService() *zcron.Cron {
	var c config.Config
	conf.MustLoad(*configFile, &c)
	c.MustSetUp()

	ctx := svc.NewServiceContext(c)
	job := handler.Init(ctx)
	fmt.Println("Starting job service...")
	return job
}
